package indigo.descriptors
{
	import indigo.modules.ModuleInfo;
	import indigo.modules.ModulesManager;
	import indigo.register.IObjectDefinitionRegistry;

	public class ApplicationContextDescriptor extends ObjectDefinitionDescriptor
	{
		protected const qModules:QName = new QName(xmlns,NodeKind.MODULES);
		protected const qModule:QName = new QName(xmlns,NodeKind.MODULE);
		
		public function ApplicationContextDescriptor(registry:IObjectDefinitionRegistry)
		{
			super(registry);
		}
		
		public override function parse(source:Object):void {
			var root:XML = XML(source);
			var modules:XMLList = root.child(qModules).child(qModule);
			
			var moduleInfo:ModuleInfo;
			for each(var module:XML in modules) {
				moduleInfo = new ModuleInfo(module);
				ModulesManager.addModule(moduleInfo);
			}
			
			super.parse(source);
		}
	}
}